﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Sbook.Control.Menu
{
    public partial class MenuRight : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                this.LoadMenu();
                    
            }
        }

        protected void LoadMenu()
        {
            List<Data.CategoryInfo> listC = Business.CategoryService.Category_GetByAll().FindAll(c => c.cpID == "0"&&c.cStatus=="1");
            if (listC.Count > 0)
            {
                //ltMenuRight.Text += "<h2 class=\"menu_head\">-" + listC[0].cName + "</h2>";
                for (int i = 0; i < listC.Count; i++)
                {
                    ltMenuRight.Text += "<h2 class=\"menu_head\">-" + listC[i].cName + "</h2>";
                    List<Data.CategoryInfo> listCC = Business.CategoryService.Category_GetByAll().FindAll(c => c.cpID == listC[i].cID && c.cStatus == "1" && Business.CategoryService.Category_GetById(c.cpID)[0].cStatus == "1");
                    
                    ltMenuRight.Text += "<ul id=\"f1\">";
                    if (listCC.Count > 0)
                    {
                        for (int j = 0; j < listCC.Count; j++)
                        {
                            ltMenuRight.Text += "<li style=\"width:200px\"><a href=\"Menu_Right.aspx?Product=" + listCC[j].cID + "\">" + listCC[j].cName + "</a></li>";
                        }
                        ltMenuRight.Text += "</ul>";
                        //ltMenuRight.Text += "<h2 class=\"menu_head\">-" + listC[i].cName + "</h2>";
                    }
                }
            }

        }
    }
}